!HID User Manual - AltKeys

AltKeys - Technical backgrounds |

Triggered by the article 'The Alt Key' (Archive April 2000) I felt it was time to sit down and find an easier way to enter the various special characters from the keyboard. This has resulted in a small relocatable module that can be added to the boot sequence, allowing an easy and intuitive manner of entering the special characters. Although everyone needs to enter special characters from time to time, I think for users in some countries (e.g. France) this can be an invaluable tool.

Current situation |

In the current situation, special characters can be entered in any of the following ways:

1) By using the !Chars application from Apps:!Chars 2) By pressing three digits on the numerical keyboard whilst holding down Alt 3) By pressing a letter key whilst holding down Alt

The !Chars application proves to be very useful and does exactly what it is supposed to, but is very unpractible when typing text. Furthermore the application quits itself when the window is closed, so it needs to be restarted each time a character is wanted. Leaving the window on the screen may produce 'random' characters when the Shift Key is pressed whilst the mouse pointer is inside the !Chars window. Pressing three digits from the numerical keyboard whilst holding down Alt allows any character to be entered as long as its ASCII code is remembered. Although it is possible to remember the most commonly used codes (e.g. Alt-134 for the bullet) this is not very helpful when typing a foreign text. The third method, pressing a letter key whilst holding down Alt, seems a better method, but is not very intuitive in many cases as Paul's article demonstrates.

A possible solution |

Years ago DEC terminals used to have a Compose Key that allowed the user to construct any special character from two other characters. All you needed to do was to press the Compose Key to enter compose mode and then, intuitively, press two keys on the keyboard to 'compose' the special character. Back in 1990 I wrote a RISC OS module that did exactly that. The only problem was that is was written to run under RISC OS 3.10 and when the Risc PC was introduced (i.e. RISC OS 3.50) it refused to run. In fact it crashed the machine when it was loaded. The reason for this incompatibility was the fact that Acorn had completely changed the way the keyboard was interpreted by the Kernel when they moved over to IBM compatible keyboards. In fact, the operating system is now much more flexible allowing foreign keyboard to be used as well, but writing a new keyboard driver has become a tedious task. Reading Paul's article last month triggered me to dig into the matter once again to see if it was possible to add a further method of entering special characters directly from the keyboard, without discarding the existing ones. The result after one evening of programming is the AltKeys module as described below.

The AltKeys module |

The AltKeys module can be loaded simply by double clicking it. If you want to use it permanently, you may add it to your PreDesk directory inside !Boot. Please note that AltKeys will only work on RISC OS 3.50 or later (it is RISC OS 4 compatible). Once the module is loaded, all keyboard operations are transparent. You can still type any key or key combination as before and use any of the other methods for entering special characters.

|  | Compose Mode can be entered by pressing and releasing the Alt Key. The CapsLock LED on the keyboard will start flashing to show that you are now in Compose Mode. Next, type two characters in sequence (e.g. 'c' and 'o') to form a special character (the © in this case). That's all! If you've pressed the Alt Key accidently and the CapsLock LED starts flashing, just press it again to cancel the Compose Mode. If the Alt Key is held down for more than 50 cs (halve a second), Compose Mode is also cancelled, to allow for programs such as ArtWorks to use the Alt Key whilst dragging.

When entering a special character, all you need to do is think of an intuitive key combination. E.g. The pound sign £ can be thought of as an L and a - sign. The é can be build from e and and the ë consists of a e and . If you can think of only one character, press it twice, e.g. 1 and 1 will give ¹ (a superscript one). I've tried to include as many key combinations as possible. As a result of this there is often more then one way to enter a character. Some examples:

ç (the french c-cedilla) can be entered as: c, C and comma (as some people call it a comma) c5 Some say the little tail looks like a (5) c? or a reversed question mark (?) cc or just press (c) twice ë can be entered as: e" the quote resembles the double dot e: the colon resembles the double dot e; so that you don't have to press Shift

Some other useful examples:

± +- œ |- ® RO © CO  tm ¥ Y- ß ss ½ 12 ÷ :-  ** ³ 33 ñ n~ ° oo

In some cases you may use the abbreviation of a character, e.g.

¶ pi ° dg (for degrees), or use (gr) as used in some countries § pg (for paragraph), or use (pa), or (se) for section ß rs (for ringel-s, the German name for it) Ž pm (for promille), or use (%o)  bu (for bullet), or (ul) for useful list, (bp) big point · cp (for centre point)

* Command |

At present, the module has only one *-command that allows you to display all the key combinations it knows of. Type *AltKey_List from the command line (or a task window) to show the full table.

Enhancements |

The list is long, but by no means complete. If you've got any combination that doesn't work and you feel it should, please email me and (if it makes sense) I'll include it in the next release. Furthermore, any suggestions for improvement are very welcome. At present the module is only suitable for Latin-1 encoded fonts, but it may be possible to add user tables or encodings in the future. Just let me know what you think. The *AltKey_List command could also be improved to give a more useful list.

How it works (the technical stuff) |

|  | Because of the way the keyboard interface is implemented in the operating system, it is not easy to intercept and modify key presses. As you can see in the drawing, the keyboard generates scan codes that are send to the Keyboard Device Driver. This Device Driver translates the scan codes into low level key numbers (as used in previous versions of the OS). These low level key numbers are then sent trough the vector 'KeyV' to the Kernel to allow for debouncing, auto-repeat, etc. The Kernel then sends the low level key codes on to the Keyboard Handler which in turn translates the key codes into ASCII characters (allowing different Keyboard Handlers for foreign keyboards). Once tranlated into ASCII, the Keyboard Handler sends the characters through the vector 'InsV' to the keybord buffer where they are interpreted. The AltKeys module intercepts both the KeyV and InsV vectors. When the Alt Key is pressed and released, Compose Mode is entered and all characters through InsV are intercepted and recorded. Once two characters are received, it leaves Compose Mode and tries to interpret the two recorded characters by scanning through a look up table. If no match is found, the combination is lost and no character will be shown. If the module finds a match, the resulting character is inserted into the keyboard buffer. Because of the way in which the keyboard buffer works, an extra problem was introduced. OS_Bytes 221 to 228 can be used to program the interpretation of certain groups of ASCII codes, e.g. to allow for F-keys to be used. By default the WIMP is set up in such a way that some ASCII codes are converted into something else. Furthermore the user (or programmer) is free to redefine the key interpretation. The AltKeys module overcomes this problem by changeing the key interpretation into a 1-to-1 relation temporarily and reverting to the previous setting on the next key press.

Links |

How to use AltKeys Back to the Keyboard pages Main index

| © Copyright Paul Reuvers X-Ample Technology bv usb@xat.nl Last changed: Last changed: Wednesday, 31 March 2004 - 13:34 CET.